const app = getApp()
Page({
  data: {
    loadingHidden: false,//代表出现加载
    user_id:'',
    id:'',
    getdata:{},
    smallcovershow:false,//小弹窗是否显示
  },
//关闭遮罩
  closebigmask: function (e) {
    this.setData({ smallcovershow: false });
  },
  //创造
  create: function (e) {
    if (this.data.getdata){
      if (this.data.getdata.cid==6){
         wx.navigateTo({
            url: '../classcard/classcard'
          })
      }else{
        wx.navigateTo({
          url: '../found/found'
        })
      }
    }else{
      wx.switchTab({
        url: '../publish/publish'
      })
    }
  },
  //删除相册记录
  deldata: function (event) {
    var user_id = app.globalData.bindInfo.user_id;
    var openid = app.globalData.openid;
    var link = app.globalData.schlink;
    var that = this;
    var getdata = that.data.getdata;
    var id = getdata.id;
    var sort = event.currentTarget.dataset.sort;
    if (user_id == "" || user_id == null || user_id == undefined) {
      return;
    }
    if (id == "" || id == null || id == undefined) {
      return;
    }
    wx.showModal({
      title: '确定删除此记录?',
      content: '',
      success: function (res) {
        if (res.confirm) {
          wx.request({
            url: getApp().globalData.baseUrl + 'delphotodata',
            data: {
              id: id,
              user_id: user_id,
              link: link,
              openid: openid
            },
            method: "post",
            header: {
              "Content-Type": "application/x-www-form-urlencoded"  //post
            },
            success: function (res) {
              if (res.data.code == 200) {
                if (getdata.cid==6){
                  wx.navigateTo({
                    url: '../classcard/classcard'
                  })
                }
                if (getdata.cid == 7) {
                  wx.navigateTo({
                    url: '../found/found'
                  })
                }
              }
            }
          })
        }else{
          that.setData({ smallcovershow: false });
        }
      }
    })
  },
  //操作 小弹窗出现 遮罩出现
  operation: function (e) {
    var that = this;
    var data = that.data.getdata;
    that.setData({smallcovershow: true});
  },
  onLoad: function (options) {
    var id = options.id;
    var that=this;
    var openid = app.globalData.openid;
    var link = app.globalData.schlink;
    var user_id = app.globalData.bindInfo.user_id;
    that.setData({ user_id: user_id });
    if (id){
      wx.request({
        url: getApp().globalData.baseUrl + 'getphotodetail',
        data: {
          openid: openid,
          link:link,
          id:id
        },
        method: "get",
        header: {},
        success: function (res) {
          if (res.data.code==200){
            if (res.data.data.user_name){
              that.setData({ getdata: res.data.data });
            }
          }
          that.setData({ loadingHidden: true });
        }
      })
    }
    that.setData({ loadingHidden: true });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})